package com.wolfking.jeesite.condition;

import com.wolfking.jeesite.util.OsUtils;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.core.type.AnnotatedTypeMetadata;


@Order(Ordered.LOWEST_PRECEDENCE - 20)
class OnWindowsCondition extends SpringBootCondition {

    @Override
    public ConditionOutcome getMatchOutcome(ConditionContext context,
                                            AnnotatedTypeMetadata metadata) {
        boolean result = OsUtils.isWindows();
        return new ConditionOutcome(result, ConditionMessage
                .forCondition(ConditionalOnWindows.class, "windows")
                .resultedIn(result));
    }
}
